<template>
  <div>
    <ul>
      <li v-for="(item,index) in listData" :key="index" @click="sendUrl(item)">
      <div>

        <icon-font :type="iconName" />
        <img v-if="!isTop" :src="item.singAl.picUrl" alt="">
        <img v-else :src="item.songImg" alt="">
        <div class="sing_Text">{{ item.songName }}</div>
      </div>

        <div class="sing_Time" v-if="showTime">{{ listData.length*100}}</div>
        <div class="sing_singer">{{ item.singer }}</div>
      </li>
    </ul>
  </div>
</template>

<script lang="ts" setup>
import { ref, computed, watchEffect } from 'vue'
import { IconFont } from '@/base-ui/Icons/index'
import { useStore } from '@/store'
import emitterPlay from "@/utils/mittEvent"


const store = useStore()


const props = withDefaults(
  defineProps<{
    iconName?: string
    songList?: any
    showTime?: boolean
    isTop?: boolean
  }>(), {
  iconName: 'icon-xiaoyuanyinle',
  songList: [
  ],
  showTime: false,
  isTop: false
}
)

const listData = ref()

watchEffect(() => {
   listData.value = props.songList
})


const iconName = props.iconName



const sendUrl = (item: any) => {
  store.dispatch('main/getSingUrlAction', item.singID)
  if (store.state.main.singUrl === null) {
    window.alert('暂无版权!🚀')
  } else {
    emitterPlay.emit("play", store.state.main.singUrl);
  }
}


</script>
<style lang="less" scoped>
li {
  list-style: none;
  padding: 10px;
  margin-top: 20px;
  margin-left: -10px;
  height: 50px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  line-height: 20px;
  background: none;
  transition: margin-left 0.5s;
  &:hover {
    margin-left: 0;
    width: 800px;
    outline: none;
    font-size: 14px;
    text-align: left;
    font-weight: 750;
    border-radius: 8%;
    // background-color: black;
    box-shadow: 0.5rem 0.5rem 1rem @greyLight-2, -0.4rem -0.4rem 1rem @white;
  }
  span {
    font-size: 28px;
  }
  .sing_Text {
    display: inline;
    font-size: 16px;
    margin-left: 10px;
  }
  .sing_singer {
    display: inline;
    font-size: 12px;
    float: right;
    margin-right: 30px;
  }
  .sing_Time{
    padding-left: 80px;
    display: inline;
    font-size: 12px;
    float: right;
    margin-right: 10px;
  }
}
img{
  width: 40px;
  height: 40px;
}
</style>
